package tianrun.ziguan.api.calculate.config.utils;

import java.math.RoundingMode;
import java.text.DecimalFormat;

public class DecimalFormatUtil {
    private static final DecimalFormat df = new DecimalFormat("#.########");

    static {
        df.setRoundingMode(RoundingMode.HALF_UP);
    }

    /**
     * 保留位数8
     *
     * @param asDouble
     * @return
     */
    public static Double parseDoubleByEight(Double asDouble) {
        if (asDouble==null)return null;
        asDouble = Double.parseDouble(df.format(asDouble));
        return asDouble;
    }
}
